#include "stdafx.h"
#include "Fakes/FakeD3D10Device.h"
#include "Fakes/FakeD3D10Resource.h"
#include "Fakes/FakeD3D10ShaderResourceView.h"
#include "Fakes/FakeD3D10Texture1D.h"
#include "Fakes/FakeD3D10Texture2D.h"
#include "Fakes/FakeD3D10Texture3D.h"

DESCRIPTION_10_TEST_SUITE_CTOR(ShaderResourceViewDescription, (D3D10_SRV_DIMENSION_TEXTURE1D))

BOOST_AUTO_TEST_CASE(TestShaderResourceViewDescription_DefaultTexture1D)
{
	rt::D3D10::ShaderResourceViewDescription desc(D3D10_SRV_DIMENSION_TEXTURE1D);
	BOOST_REQUIRE_EQUAL(D3D10_SRV_DIMENSION_TEXTURE1D, desc.ViewDimension);
	BOOST_REQUIRE_EQUAL(DXGI_FORMAT_UNKNOWN, desc.Format);
}

DESCRIPTION_10_TEST_CASE(DXGI_FORMAT, Format, DXGI_FORMAT_R8G8B8A8_UINT, ShaderResourceViewDescription)

BOOST_FIXTURE_TEST_CASE(Create, TestShaderResourceViewDescription)
{
	FakeD3D10Device device;
	FakeD3D10ShaderResourceView view;
	FakeD3D10Resource resource;
	device.CreateShaderResourceViewFakeResult = &view;
	device.CreateShaderResourceViewFakeHResult = S_OK;
	ID3D10ShaderResourceView *result = m_desc.Create(&device, &resource);
	BOOST_REQUIRE(device.CreateShaderResourceViewCalled);
	BOOST_REQUIRE_EQUAL(&m_desc, device.CreateShaderResourceViewLastDesc);
	BOOST_REQUIRE_EQUAL(&resource, device.CreateShaderResourceViewLastResource);
	BOOST_REQUIRE_EQUAL(&view, result);
}

TEXTURE_SETTER_TEST_CASE_DEFAULT(FormatFromTexture1D, TestShaderResourceViewDescription, Format, \
								 FakeD3D10Texture1D, Texture1DDescription(DXGI_FORMAT_R8G8B8A8_UINT, 256), \
								 Format, DXGI_FORMAT, DXGI_FORMAT_R8G8B8A8_UINT)

TEXTURE_SETTER_TEST_CASE_DEFAULT(FormatFromTexture2D, TestShaderResourceViewDescription, Format, \
								 FakeD3D10Texture2D, Texture2DDescription(DXGI_FORMAT_R8G8B8A8_UINT, 256, 256), \
								 Format, DXGI_FORMAT, DXGI_FORMAT_R8G8B8A8_UINT)

TEXTURE_SETTER_TEST_CASE_DEFAULT(FormatFromTexture3D, TestShaderResourceViewDescription, Format, \
								 FakeD3D10Texture3D, Texture3DDescription(DXGI_FORMAT_R8G8B8A8_UINT, 256, 256, 256), \
								 Format, DXGI_FORMAT, DXGI_FORMAT_R8G8B8A8_UINT)

BOOST_AUTO_TEST_SUITE_END()
